//
//  HJCommonViewCell.m
//  GAMCAfterSales
//
//  Created by 贺佳 on 2018/7/31.
//  Copyright © 2018年 glendale. All rights reserved.
//

#import "HJCommonViewCell.h"

@implementation HJCommonViewCell

UITablecellM(@"HJCommonViewCell")
-(void)setUI{
    self.selectionStyle=UITableViewCellSelectionStyleNone;
}
-(void)setContentAry:(NSArray<HJCommonTitleCellModel *> *)contentAry
{
    _contentAry=contentAry;
    [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    UILabel*lastLabel;
    NSInteger totalFlex = 0;
    for (HJCommonTitleCellModel*model in contentAry) {
        totalFlex+=model.flex;
    }
    WEAKSELF;
    for (int i=0; i<contentAry.count; i++) {
        HJCommonTitleCellModel*model=contentAry[i];
        UILabel*contentLabel=[[UILabel alloc]init];
        contentLabel.text=model.content;
        contentLabel.textAlignment=NSTextAlignmentCenter;
        contentLabel.font=HJFont(13);
        [self.contentView addSubview:contentLabel];
        [contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(lastLabel?lastLabel.mas_right:weakSelf.contentView).offset(lastLabel?1:0);
            make.top.bottom.mas_equalTo(weakSelf.contentView);
            make.width.mas_equalTo(weakSelf.contentView).multipliedBy(model.flex*1.0/totalFlex);
        }];
        lastLabel=contentLabel;
    }
}
@end
